<?php

namespace app\apiadmin\model\unionapp;

use app\common\utils\Res;
use think\Model;
use think\facade\Db;

class UnionAppModel extends Model
{
    
    protected $name = "siyu_course";

    protected $pk = "id";

    public static function getGoodsInfo($map,$findName){

         try {
            $data =  self::alias('o')
            ->field($findName)
            ->join('xh_siyu_teacher t ',' o.teacher_id = t.id')
            ->where($map)->order('o.create_time desc')->find();
            return $data;
        } catch (\PDOException $th) {
            Res::error($th->getMessage());
        }

    }

    public static function createOrder($map){

        try {
            $data = Db::name('siyu_order')->insert($map);
            return $data;
        } catch (\Exception $e) {
            return Res::error($e->getMessage());
        }

    }

    public static function getTanKaInfo($map,$findName){

        try {
            $data = Db::name('siyu_tanka')
            ->field($findName)
            ->alias('t')
            ->join('xh_siyu_course c','c.id = t.courseid')
            ->where($map)->find();
            return $data;
        } catch (\Exception $e) {
            return Res::error($e->getMessage());
        }

    }


}